/**
 * Copyright 2014 wasu.com
 *
 *
 * Create on 2015-5-17 下午1:46:58
 */
package xiaojian.toolkit.base;

import xiaojian.toolkit.util.MutablePropertyable;
import xiaojian.toolkit.util.Propertyable;

/**
 * @author <a href="mailto:caoxiaojian@wasu.com>xiaojian.cao</a>
 * 
 */
public class TransportUtils {

	private static final String TRANSPORT_SENDER = "TRANSPORT_SENDER";

	public static Object attachSender(Object mutablePropertyable, Sender sender) {
		if (mutablePropertyable instanceof MutablePropertyable) {
			((MutablePropertyable) mutablePropertyable).setProperty(
					TRANSPORT_SENDER, sender);
		}

		return mutablePropertyable;
	}

	public static Sender getSenderOf(Object propertyable) {
		if (propertyable instanceof Propertyable) {
			return (Sender) ((Propertyable) propertyable)
					.getProperty(TRANSPORT_SENDER);
		}
		return null;
	}
}
